// Copyright (c) 2017 Isara Technologies. All Rights Reserved.

#include "HttpStatusCode.h"
#include "UnrealWebServerPrivatePCH.h"

FString HttpStatusCodeToString(const EHttpStatusCode httpStatusCode)
{
	switch (httpStatusCode) {
	case EHttpStatusCode::VE_Continue:
		return FString("100");
	case EHttpStatusCode::VE_SwitchingProtocols:
		return FString("101");
	case EHttpStatusCode::VE_Processing:
		return FString("102");
	case EHttpStatusCode::VE_OK:
		return FString("200 OK");
	case EHttpStatusCode::VE_Created:
		return FString("201");
	case EHttpStatusCode::VE_Accepted:
		return FString("202");
	case EHttpStatusCode::VE_NonAuthoritativeInformation:
		return FString("203");
	case EHttpStatusCode::VE_NoContent:
		return FString("204");
	case EHttpStatusCode::VE_ResetContent:
		return FString("205");
	case EHttpStatusCode::VE_PartialContent:
		return FString("206");
	case EHttpStatusCode::VE_MultiStatus:
		return FString("207");
	case EHttpStatusCode::VE_AlreadyReported:
		return FString("208");
	case EHttpStatusCode::VE_ImUsed:
		return FString("226");
	case EHttpStatusCode::VE_MultipleChoices:
		return FString("300");
	case EHttpStatusCode::VE_MovedPermanently:
		return FString("301");
	case EHttpStatusCode::VE_Found:
		return FString("302");
	case EHttpStatusCode::VE_SeeOther:
		return FString("303");
	case EHttpStatusCode::VE_NotModified:
		return FString("304");
	case EHttpStatusCode::VE_UseProxy:
		return FString("305");
	case EHttpStatusCode::VE_SwitchProxy:
		return FString("306");
	case EHttpStatusCode::VE_TemporaryRedirect:
		return FString("307");
	case EHttpStatusCode::VE_PermanentRedirect:
		return FString("308");
	case EHttpStatusCode::VE_BadRequest:
		return FString("400");
	case EHttpStatusCode::VE_Unauthorized:
		return FString("401");
	case EHttpStatusCode::VE_PaymentRequired:
		return FString("402");
	case EHttpStatusCode::VE_Forbidden:
		return FString("403");
	case EHttpStatusCode::VE_NotFound:
		return FString("404");
	case EHttpStatusCode::VE_MethodNotAllowed:
		return FString("405");
	case EHttpStatusCode::VE_NotAcceptable:
		return FString("406");
	case EHttpStatusCode::VE_ProxyAuthenticationRequired:
		return FString("407");
	case EHttpStatusCode::VE_RequestTimeout:
		return FString("408");
	case EHttpStatusCode::VE_Conflict:
		return FString("409");
	case EHttpStatusCode::VE_Gone:
		return FString("410");
	case EHttpStatusCode::VE_LengthRequired:
		return FString("411");
	case EHttpStatusCode::VE_PreconditionFailed:
		return FString("412");
	case EHttpStatusCode::VE_PayloadTooLarge:
		return FString("413");
	case EHttpStatusCode::VE_UriTooLong:
		return FString("414");
	case EHttpStatusCode::VE_UnsupportedMediaType:
		return FString("415");
	case EHttpStatusCode::VE_RangeNotSatisfiable:
		return FString("416");
	case EHttpStatusCode::VE_ExpectationFailed:
		return FString("417");
	case EHttpStatusCode::VE_ImATeapot:
		return FString("418");
	case EHttpStatusCode::VE_MisdirectedRequest:
		return FString("421");
	case EHttpStatusCode::VE_UnprocessableEntity:
		return FString("422");
	case EHttpStatusCode::VE_Locked:
		return FString("423");
	case EHttpStatusCode::VE_Failed:
		return FString("424");
	case EHttpStatusCode::VE_UpgradeRequired:
		return FString("426");
	case EHttpStatusCode::VE_PreconditionRequired:
		return FString("428");
	case EHttpStatusCode::VE_TooManyRequests:
		return FString("429");
	case EHttpStatusCode::VE_RequestHeaderFieldsTooLarge:
		return FString("431");
	case EHttpStatusCode::VE_UnavailableForLegalReasons:
		return FString("451");
	case EHttpStatusCode::VE_InternalServerError:
		return FString("500");
	case EHttpStatusCode::VE_NotImplemented:
		return FString("501");
	case EHttpStatusCode::VE_BadGateway:
		return FString("502");
	case EHttpStatusCode::VE_ServiceUnavailable:
		return FString("503");
	case EHttpStatusCode::VE_GatewayTimeout:
		return FString("504");
	case EHttpStatusCode::VE_HttpVersionNotSupported:
		return FString("505");
	case EHttpStatusCode::VE_VariantAlsoNegotiates:
		return FString("506");
	case EHttpStatusCode::VE_InsufficientStorage:
		return FString("507");
	case EHttpStatusCode::VE_LoopDetected:
		return FString("508");
	case EHttpStatusCode::VE_NotExtended:
		return FString("510");
	case EHttpStatusCode::VE_NetworkAuthenticationRequired:
		return FString("511");
	default:
		return FString("");	// TODO Throw exception
	}
}

int32 HttpStatusCodeToInt(const EHttpStatusCode httpStatusCode)
{
	switch (httpStatusCode) {
	case EHttpStatusCode::VE_Continue:
		return 100;
	case EHttpStatusCode::VE_SwitchingProtocols:
		return 101;
	case EHttpStatusCode::VE_Processing:
		return 102;
	case EHttpStatusCode::VE_OK:
		return 200;
	case EHttpStatusCode::VE_Created:
		return 201;
	case EHttpStatusCode::VE_Accepted:
		return 202;
	case EHttpStatusCode::VE_NonAuthoritativeInformation:
		return 203;
	case EHttpStatusCode::VE_NoContent:
		return 204;
	case EHttpStatusCode::VE_ResetContent:
		return 205;
	case EHttpStatusCode::VE_PartialContent:
		return 206;
	case EHttpStatusCode::VE_MultiStatus:
		return 207;
	case EHttpStatusCode::VE_AlreadyReported:
		return 208;
	case EHttpStatusCode::VE_ImUsed:
		return 226;
	case EHttpStatusCode::VE_MultipleChoices:
		return 300;
	case EHttpStatusCode::VE_MovedPermanently:
		return 301;
	case EHttpStatusCode::VE_Found:
		return 302;
	case EHttpStatusCode::VE_SeeOther:
		return 303;
	case EHttpStatusCode::VE_NotModified:
		return 304;
	case EHttpStatusCode::VE_UseProxy:
		return 305;
	case EHttpStatusCode::VE_SwitchProxy:
		return 306;
	case EHttpStatusCode::VE_TemporaryRedirect:
		return 307;
	case EHttpStatusCode::VE_PermanentRedirect:
		return 308;
	case EHttpStatusCode::VE_BadRequest:
		return 400;
	case EHttpStatusCode::VE_Unauthorized:
		return 401;
	case EHttpStatusCode::VE_PaymentRequired:
		return 402;
	case EHttpStatusCode::VE_Forbidden:
		return 403;
	case EHttpStatusCode::VE_NotFound:
		return 404;
	case EHttpStatusCode::VE_MethodNotAllowed:
		return 405;
	case EHttpStatusCode::VE_NotAcceptable:
		return 406;
	case EHttpStatusCode::VE_ProxyAuthenticationRequired:
		return 407;
	case EHttpStatusCode::VE_RequestTimeout:
		return 408;
	case EHttpStatusCode::VE_Conflict:
		return 409;
	case EHttpStatusCode::VE_Gone:
		return 410;
	case EHttpStatusCode::VE_LengthRequired:
		return 411;
	case EHttpStatusCode::VE_PreconditionFailed:
		return 412;
	case EHttpStatusCode::VE_PayloadTooLarge:
		return 413;
	case EHttpStatusCode::VE_UriTooLong:
		return 414;
	case EHttpStatusCode::VE_UnsupportedMediaType:
		return 415;
	case EHttpStatusCode::VE_RangeNotSatisfiable:
		return 416;
	case EHttpStatusCode::VE_ExpectationFailed:
		return 417;
	case EHttpStatusCode::VE_ImATeapot:
		return 418;
	case EHttpStatusCode::VE_MisdirectedRequest:
		return 421;
	case EHttpStatusCode::VE_UnprocessableEntity:
		return 422;
	case EHttpStatusCode::VE_Locked:
		return 423;
	case EHttpStatusCode::VE_Failed:
		return 424;
	case EHttpStatusCode::VE_UpgradeRequired:
		return 426;
	case EHttpStatusCode::VE_PreconditionRequired:
		return 428;
	case EHttpStatusCode::VE_TooManyRequests:
		return 429;
	case EHttpStatusCode::VE_RequestHeaderFieldsTooLarge:
		return 431;
	case EHttpStatusCode::VE_UnavailableForLegalReasons:
		return 451;
	case EHttpStatusCode::VE_InternalServerError:
		return 500;
	case EHttpStatusCode::VE_NotImplemented:
		return 501;
	case EHttpStatusCode::VE_BadGateway:
		return 502;
	case EHttpStatusCode::VE_ServiceUnavailable:
		return 503;
	case EHttpStatusCode::VE_GatewayTimeout:
		return 504;
	case EHttpStatusCode::VE_HttpVersionNotSupported:
		return 505;
	case EHttpStatusCode::VE_VariantAlsoNegotiates:
		return 506;
	case EHttpStatusCode::VE_InsufficientStorage:
		return 507;
	case EHttpStatusCode::VE_LoopDetected:
		return 508;
	case EHttpStatusCode::VE_NotExtended:
		return 510;
	case EHttpStatusCode::VE_NetworkAuthenticationRequired:
		return 511;
	default:
		return -1;	// TODO Throw exception
	}
}